{% extends 'window.twig' %}
{% block body %}
    <div class="admin-main-container">
        <form action="auth.rule.add" method="post"class="form-horizontal data-view data-validate" post-type="ajax">
            <div class="with-padding">
                <div class="form-item">
                    <div class="item-label">资源标识
                        <span class="check-tips">（标识唯一不能重复）</span>
                        <label id="name-error" class="error" for="name"></label>
                    </div>
                    <div class="controls">
                        <input type="text" class="form-control" name="name" remote-type="post"
                               data-rules="required remote" remote-url="rule.exists"
                               data-message-required="请输入资源标识">
                    </div>
                </div>
                <div class="form-item">
                    <div class="item-label">资源名称<span class="check-tips"></span>
                        <label id="title-error" class="error" for="title"></label>
                    </div>
                    <div class="controls">
                        <input type="text" class="form-control" name="title" data-rules="required remote"
                               data-message-required="请输入资源名称">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">类型<span class="check-tips"></span></label>
                    <div class="controls">
                        <select class="form-control" name="type">
                            <option value="1">网络链接</option>
                            <option value="2">按钮/资源</option>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">状态<span class="check-tips"></span></label>
                    <div class="controls">

                        <select class="form-control" name="status">
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">条件<span class="check-tips"></span></label>
                    <div class="controls">
                        <input type="text" class="form-control" name="condition" value="">
                    </div>
                </div>
                <div class="form-item">
                    <label class="item-label">上级标识<span class="check-tips">（所属的上级标识）</span></label>
                    <div class="controls">
                        <select name="parent" class="form-select-size form-control">
                            <option value="0">顶级菜单</option>
                            {% for r in rules %}
                            <option value="{{ r.id }}">{{ r.title|raw }}</option>
                                {% for rc in r.child %}
                                    <option value="{{ rc.id }}">|--{{ rc.title|raw }}</option>
                                    {% for rcc in rc.child %}
                                        <option value="{{ rcc.id }}">|----{{ rcc.title|raw }}</option>
                                    {% endfor %}
                                {% endfor %}
                            {% endfor %}
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-item with-padding" style="margin-top: 10px;">
                <button class="btn btn-primary" type="submit" target-form="form-horizontal">确 定</button>
                <a class="btn btn-info" href="../rule.html">返 回</a>
            </div>
        </form>
    </div>
{% endblock %}